<script>
export default {
  name: 'ProgressItem',
  props: {
    label: {
      type: String,
      required: true,
    },
    current: {
      type: Number,
      required: true,
    },
    total: {
      type: Number,
      required: true,
    },
    isExpired: {
      type: Boolean,
      default: false,
    },
  },
  computed: {
    progressPercentage() {
      return (this.current / this.total) * 100
    },
  },
}
</script>

<template>
  <view class="progress-item" :class="{ 'is-expired': isExpired }">
    <view class="progress-item-label">
      {{ label }}
    </view>
    <view class="progress-bar">
      <view class="progress" :style="{ width: `${progressPercentage}%` }" />
    </view>
    <view class="count">
      <text class="current-number ml-4">
        {{ current }}
      </text>/{{ total }}
      <text v-if="isExpired" class="expired-text">
        (已到期)
      </text>
    </view>
  </view>
</template>

<style scoped lang="scss">
.progress-item {
    color: #666;
    font-size: 12px;
    display: flex;
    background-color: #fff;
    border: 1rpx solid #E6E6E6;
    padding: 4rpx 16rpx;
    border-radius: 100rpx;
}

.progress-item-label {
    color: #333;
}

.progress-bar {
    height: 6px;
    background-color: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.current-number {
    font-weight: bold;
    color: $primary-highlight-color;
}

.progress {
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.3s ease;
}

.count {
    color: #666;
}

.expired-text {
    color: #999;
    margin-left: 4px;
}

/* 到期状态样式 */
.is-expired .progress-item-label,
.is-expired .count,
.is-expired .current-number {
    color: #999;
}

.is-expired .progress {
    background-color: #ccc;
}
</style>
